<template>
  <div class="search-panel">
    <el-select
      clearable
      placeholder="请选择视频搜索"
      v-model="searchForm.videoId"
      @change="loadData"
    >
      <el-option
        :value="item.videoId"
        :label="item.videoName"
        v-for="item in allVideoList"
      ></el-option>
    </el-select>
  </div>
</template>

<script setup lang="ts">
import type { VideoInfo } from '@/services/api/home'
import { loadAllVideoHttpRequest } from '@/services/api/ucenter'
import { ref } from 'vue'

const searchForm = ref({
  videoId: ''
})

const allVideoList = ref<VideoInfo[]>([])

const loadAllVideo = async () => {
  const res = await loadAllVideoHttpRequest()
  allVideoList.value = res.data
}
loadAllVideo()

const emit = defineEmits(['loadData'])
const loadData = (e: string) => {
  console.log(e, '视频数据')

  emit('loadData', e)
}
</script>

<style lang="less" scoped>
.search-panel {
  width: 200px;
  float: right;
  height: 40px;
}
</style>
